home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / 3d2split / 3d2.bas next >
Encoding:
BASIC Source File  |  1995-09-06  |  20.0 KB  |  473 lines

  1. '----------------------------------------------------------
  2. '| 3D Routines with Splitter Bars v2.0 - By Daniel Benito |
  3. '----------------------------------------------------------
  4. '
  5. ' This file contains a new version of a minute collection of simple
  6. ' routines that enable you to paint several kinds of frames around or
  7. ' inside controls and forms, adding a 3D effect to your application,
  8. ' without the need of .VBX controls or .DLLs.
  9. '
  10. ' They were written to cover a basic need, while keeping code
  11. ' simple and fast.
  12. '
  13. ' The idea of these subroutines is loosely based on a routine called
  14. ' Outlines, which is included in the VB 3.0 sample application
  15. ' VISDATA.
  16. '
  17. ' Also included is DrawOutline, a routine used with my splitter bars.
  18. '
  19. ' The author spent a while coding these routines. If you find them useful,
  20. ' he would gratefully accept ten bucks (sic), five quid, mil quinientas pelas,
  21. ' or whatever you consider adequate in your currency.
  22. '
  23. ' My postal address is:
  24. '
  25. '     Daniel Benito
  26. '     Soto Hidalgo, 8
  27. '     28042 Madrid (Spain)
  28. '
  29. ' If you have any questions, send me a message to the CIS address
  30. ' 100022,141, or post it in the MSBASIC forum.
  31.  
  32. ' 3D constants
  33. Global Const INSET = -1
  34. Global Const RAISED = 0
  35. Global Const REMOVE = 2
  36.  
  37. ' WindowState
  38. Global Const NORMAL = 0
  39. Global Const MINI = 1
  40. Global Const MAXI = 2
  41.  
  42. ' Colors
  43. Global Const BLACK = &H0&
  44. Global Const RED = &HFF&
  45. Global Const GREEN = &HFF00&
  46. Global Const YELLOW = &HFFFF&
  47. Global Const BLUE = &HFF0000
  48. Global Const MAGENTA = &HFF00FF
  49. Global Const CYAN = &HFFFF00
  50. Global Const WHITE = &HFFFFFF
  51. Global Const LIGHTGRAY = &HC0C0C0
  52. Global Const DARKGRAY = &H808080
  53.  
  54. Declare Sub DrawFocusRect Lib "User" (ByVal hDC%, lpRect As Any)
  55. Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As Any)
  56. Declare Function GetDC Lib "User" (ByVal hWnd As Integer) As Integer
  57. Declare Function ReleaseDC Lib "User" (ByVal hWnd As Integer, ByVal hDC As Integer) As Integer
  58.  
  59. Type RECT
  60.     Left As Integer
  61.     Top As Integer
  62.     right As Integer
  63.     bottom As Integer
  64. End Type
  65.  
  66. Sub CenterForm (form_name As Form)
  67.     ' Centers form_name on the screen
  68.     Screen.MousePointer = 11
  69.     form_name.Top = Screen.Height / 2 - form_name.Height / 2
  70.     form_name.Left = Screen.Width / 2 - form_name.Width / 2
  71.     Screen.MousePointer = 0
  72. End Sub
  73.  
  74. Sub DrawOutline (rt As RECT, frm As Form)
  75.  
  76. ' This subroutine paints a focus frame at the specified co-ordinates. In this example it is
  77. ' used to draw the marquee that is dragged when you drag an splitter bar.
  78. ' Note: It paints the box on screen DC, not just on the form, to make it appear above other
  79. ' controls.
  80. ' Parameters:
  81. ' rt            - The name of the rect type structure containing the coords of the box to
  82. '                 be drawn.
  83. ' frm           - The form on which to draw the frame.
  84.     
  85.     Dim wndcoord As RECT, r As RECT ' structs used for coords
  86.     Dim Dummy As Integer
  87.     DC = GetDC(0) ' Get the Device Context of the whole screen
  88.     GetWindowRect frm.hWnd, wndcoord ' Get coords of form
  89.     
  90.     ' Add pixels for border and titlebar (the coords of a form in VB do not include them)
  91.     ' The number of pixels to be added depends on the type of border
  92.  
  93.     r.Left = (rt.Left / Screen.TwipsPerPixelX) + wndcoord.Left + 1 '+ 4 sizable border
  94.     r.Top = (rt.Top / Screen.TwipsPerPixelX) + wndcoord.Top + 28 '+ 31 sizable border
  95.     r.right = (rt.right / Screen.TwipsPerPixelX) + wndcoord.Left + 1 '+ 4 sizable border
  96.     r.bottom = (rt.bottom / Screen.TwipsPerPixelX) + wndcoord.Top + 28 '+ 31 sizable border
  97.     
  98.     DrawFocusRect DC, r ' Draw the frame itself
  99.     
  100.     Dummy = ReleaseDC(0, DC) ' Release the allocated DC
  101.  
  102. End Sub
  103.  
  104. Sub InLinePic (pic_name As Control, bevel_size As Integer, dn As Integer)
  105.  
  106. ' This subroutine paints a frame inside a picture box (or any control with
  107. ' the Line method), giving it a 3D effect.
  108. '
  109. ' Parameters:
  110. ' pic_name      - The name of the picture box on which the frame is to be drawn.
  111. ' bevel_size    - Width of the bevel, in pixels.
  112. ' dn            - Indicates the style of the frame:
  113. '                   INSET   - The frame is drawn sunken.
  114. '                   RAISED  - The frame is drawn raised.
  115. '                   REMOVE  - The frame is removed (drawn in light gray).
  116.  
  117.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  118.     Dim x1 As Integer, y1 As Integer, x As Integer, y As Integer, i As Integer
  119.     Dim pleft As Integer, pright As Integer, ptop As Integer, pbottom As Integer ' coords
  120.     
  121.     Select Case dn ' assign colors depending on frame style
  122.         Case True ' Inset
  123.             col1 = DARKGRAY
  124.             col2 = WHITE
  125.             'col1 = RGB(128, 128, 128) ' Dark gray
  126.             'col2 = RGB(255, 255, 255) ' Bright white
  127.         Case False ' Raised
  128.             col1 = WHITE
  129.             col2 = DARKGRAY
  130.             'col1 = RGB(255, 255, 255) ' Bright white
  131.             'col2 = RGB(128, 128, 128) ' Dark gray
  132.         Case 2 ' Remove
  133.             col1 = LIGHTGRAY
  134.             col2 = LIGHTGRAY
  135.             'col1 = RGB(192, 192, 192) ' Light gray
  136.             'col2 = RGB(192, 192, 192) ' Light gray
  137.         Case Else ' Otherwise, it's an error
  138.             Exit Sub ' Exit subroutine
  139.     End Select
  140.     
  141.     x1 = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  142.     y1 = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  143.     
  144.     bevel_size = bevel_size - 1
  145.     
  146.     pleft = pic_name.ScaleLeft ' Assign coords
  147.     ptop = pic_name.ScaleTop
  148.     pright = pic_name.ScaleLeft + pic_name.ScaleWidth - x1 ' Take away one pixel
  149.     pbottom = pic_name.ScaleTop + pic_name.ScaleHeight - y1 ' Take away one pixel
  150.     
  151.     For i = 0 To bevel_size ' Loop depends of bevel size - draws one rectangle per bevel pixel
  152.         x = x1 * i ' Distance from picture edge
  153.         y = y1 * i ' Distance form picture edge
  154.         pic_name.Line (pleft + x, ptop + y)-(pright - x, ptop + y), col1 ' Draw the individual lines
  155.         pic_name.Line (pleft + x, ptop + y)-(pleft + x, pbottom - y), col1
  156.         pic_name.Line (pleft + x1 + x, pbottom - y)-(pright - x, pbottom - y), col2
  157.         pic_name.Line (pright - x, pbottom - y)-(pright - x, ptop + y), col2
  158.     Next i
  159.  
  160. End Sub
  161.  
  162. Sub OutlineControl (form_name As Form, ctrl_name As Control, bevel_size As Integer, dn As Integer)
  163.     
  164. ' This subroutine paints a frame on a form around a control, giving it a 3D effect.
  165. '
  166. ' Parameters:
  167. ' form_name     - The name of the form on which the control is.
  168. ' ctrl_name     - The name of the control around which the bevel is to be drawn.
  169. ' bevel_size    - Width of the bevel, in pixels.
  170. ' dn            - Indicates the style of the frame:
  171. '                   INSET   - The frame is drawn sunken.
  172. '                   RAISED  - The frame is drawn raised.
  173. '                   REMOVE  - The frame is removed (drawn in light gray).
  174.     
  175.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  176.     Dim x1 As Integer, y1 As Integer, x As Integer, y As Integer, i As Integer
  177.     Dim cleft As Integer, cright As Integer, ctop As Integer, cbottom As Integer ' coords
  178.     
  179.     Select Case dn ' assign colors depending on frame style
  180.         Case True ' Inset
  181.             col1 = DARKGRAY
  182.             col2 = WHITE
  183.             'col1 = RGB(128, 128, 128) ' Dark gray
  184.             'col2 = RGB(255, 255, 255) ' Bright white
  185.         Case False ' Raised
  186.             col1 = WHITE
  187.             col2 = DARKGRAY
  188.             'col1 = RGB(255, 255, 255) ' Bright white
  189.             'col2 = RGB(128, 128, 128) ' Dark gray
  190.         Case 2 ' Remove
  191.             col1 = LIGHTGRAY
  192.             col2 = LIGHTGRAY
  193.             'col1 = RGB(192, 192, 192) ' Light gray
  194.             'col2 = RGB(192, 192, 192) ' Light gray
  195.         Case Else ' Otherwise, it's an error
  196.             Exit Sub ' Exit subroutine
  197.     End Select
  198.     
  199.     x1 = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  200.     y1 = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  201.     
  202.     bevel_size = bevel_size - 1
  203.     
  204.     cleft = ctrl_name.Left ' Assign coords
  205.     ctop = ctrl_name.Top
  206.     cright = ctrl_name.Left + ctrl_name.Width
  207.     cbottom = ctrl_name.Top + ctrl_name.Height
  208.     
  209.     For i = 0 To bevel_size ' Loop depends of bevel size - draws one rectangle per bevel pixel
  210.         x = x1 * i ' Distance from picture edge
  211.         y = y1 * i ' Distance from picture edge
  212.         form_name.Line ((cleft - x1) - x, (ctop - y1) - y)-((cright) + x, (ctop - y1) - y), col1 ' Draw the individual lines
  213.         form_name.Line ((cleft - x1) - x, (ctop - y1) - y)-((cleft - x1) - x, (cbottom) + y), col1
  214.         form_name.Line ((cright) + x, (ctop) - y)-((cright) + x, (cbottom + y1) + y), col2
  215.         form_name.Line ((cleft) - x, (cbottom) + y)-((cright) + x, (cbottom) + y), col2
  216.     Next i
  217.  
  218. End Sub
  219.  
  220. Sub OutlineControlPic (pic_name As Control, ctrl_name As Control, bevel_size As Integer, dn As Integer)
  221.     
  222. ' This subroutine paints a frame around a control inside a picture box,
  223. ' giving it a 3D effect. This separate routine is necessary because, with controls
  224. ' insice a container, VB uses the edge of the container as the origin of the coordinates.
  225. '
  226. ' Parameters:
  227. ' pic_name      - The name of the picture box in which the control is.
  228. ' ctrl_name     - The name of the control around which the bevel is to be drawn.
  229. ' bevel_size    - Width of the bevel, in pixels.
  230. ' dn            - Indicates the style of the frame:
  231. '                   INSET   - The frame is drawn sunken.
  232. '                   RAISED  - The frame is drawn raised.
  233. '                   REMOVE  - The frame is removed (drawn in light gray).
  234.     
  235.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  236.     Dim x1 As Integer, y1 As Integer, x As Integer, y As Integer, i As Integer
  237.     Dim cleft As Integer, cright As Integer, ctop As Integer, cbottom As Integer ' coords
  238.     
  239.     Select Case dn ' assign colors depending on frame style
  240.         Case True ' Inset
  241.             col1 = DARKGRAY
  242.             col2 = WHITE
  243.             'col1 = RGB(128, 128, 128) ' Dark gray
  244.             'col2 = RGB(255, 255, 255) ' Bright white
  245.         Case False ' Raised
  246.             col1 = WHITE
  247.             col2 = DARKGRAY
  248.             'col1 = RGB(255, 255, 255) ' Bright white
  249.             'col2 = RGB(128, 128, 128) ' Dark gray
  250.         Case 2 ' Remove
  251.             col1 = LIGHTGRAY
  252.             col2 = LIGHTGRAY
  253.             'col1 = RGB(192, 192, 192) ' Light gray
  254.             'col2 = RGB(192, 192, 192) ' Light gray
  255.         Case Else ' Otherwise, it's an error
  256.             Exit Sub ' Exit subroutine
  257.     End Select
  258.     
  259.     x1 = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  260.     y1 = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  261.     
  262.     bevel_size = bevel_size - 1
  263.     
  264.     cleft = ctrl_name.Left ' Assign coords
  265.     ctop = ctrl_name.Top
  266.     cright = ctrl_name.Left + ctrl_name.Width
  267.     cbottom = ctrl_name.Top + ctrl_name.Height
  268.     
  269.     For i = 0 To bevel_size ' Loop depends of bevel size - draws one rectangle per bevel pixel
  270.         x = x1 * i ' Distance from picture edge
  271.         y = y1 * i ' Distance from picture edge
  272.         pic_name.Line ((cleft - x1) - x, (ctop - y1) - y)-((cright) + x, (ctop - y1) - y), col1 ' Draw the individual lines
  273.         pic_name.Line ((cleft - x1) - x, (ctop - y1) - y)-((cleft - x1) - x, (cbottom) + y), col1
  274.         pic_name.Line ((cright) + x, (ctop) - y)-((cright) + x, (cbottom + y1) + y), col2
  275.         pic_name.Line ((cleft) - x, (cbottom) + y)-((cright) + x, (cbottom) + y), col2
  276.     Next i
  277.  
  278. End Sub
  279.  
  280. Sub OutlineForm (form_name As Form, bevel_size As Integer, dn As Integer)
  281.  
  282. ' This subroutine paints a frame inside a form, giving it a 3D effect.
  283. '
  284. ' Parameters:
  285. ' form_name     - The name of the form on which the frame is to be drawn.
  286. ' bevel_size    - Width of the bevel, in pixels.
  287. ' dn            - Indicates the style of the frame:
  288. '                   INSET   - The frame is drawn sunken.
  289. '                   RAISED  - The frame is drawn raised.
  290. '                   REMOVE  - The frame is removed (drawn in light gray).
  291.     
  292.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  293.     Dim x1 As Integer, y1 As Integer, x As Integer, y As Integer, i As Integer
  294.     Dim fleft As Integer, fright As Integer, ftop As Integer, fbottom As Integer ' coords
  295.     
  296.     Select Case dn ' assign colors depending on frame style
  297.         Case True ' Inset
  298.             col1 = DARKGRAY
  299.             col2 = WHITE
  300.             'col1 = RGB(128, 128, 128) ' Dark gray
  301.             'col2 = RGB(255, 255, 255) ' Bright white
  302.         Case False ' Raised
  303.             col1 = WHITE
  304.             col2 = DARKGRAY
  305.             'col1 = RGB(255, 255, 255) ' Bright white
  306.             'col2 = RGB(128, 128, 128) ' Dark gray
  307.         Case 2 ' Remove
  308.             col1 = LIGHTGRAY
  309.             col2 = LIGHTGRAY
  310.             'col1 = RGB(192, 192, 192) ' Light gray
  311.             'col2 = RGB(192, 192, 192) ' Light gray
  312.         Case Else ' Otherwise, it's an error
  313.             Exit Sub ' Exit subroutine
  314.     End Select
  315.     
  316.     x1 = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  317.     y1 = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  318.     
  319.     bevel_size = bevel_size - 1
  320.     
  321.     
  322.     fleft = form_name.ScaleLeft ' Assign coords
  323.     ftop = form_name.ScaleTop
  324.     fright = form_name.ScaleLeft + form_name.ScaleWidth - x1 ' Take away one pixel
  325.     fbottom = form_name.ScaleTop + form_name.ScaleHeight - y1 ' Take away one pixel
  326.     
  327.     For i = 0 To bevel_size ' Loop depends of bevel size - draws one rectangle per bevel pixel
  328.         x = x1 * i ' Distance from picture edge
  329.         y = y1 * i ' Distance from picture edge
  330.         form_name.Line (fleft + x, ftop + y)-(fright - x, ftop + y), col1 ' Draw the individual lines
  331.         form_name.Line (fleft + x, ftop + y)-(fleft + x, fbottom - y), col1
  332.         form_name.Line (fleft + x1 + x, fbottom - y)-(fright - x, fbottom - y), col2
  333.         form_name.Line (fright - x, fbottom - y)-(fright - x, ftop + y), col2
  334.     Next i
  335.     
  336. End Sub
  337.  
  338. Sub OutlinePic (form_name As Form, ctrl_name As Control, dn As Integer)
  339.     
  340. ' This subroutine paints a 3D rectangle, with a 1 pixel bevel, around a picture box.
  341. ' Although this routine is meant to draw around a container, it can be used with any control.
  342. '
  343. ' Parameters:
  344. ' form_name     - The name of the form on which the picture box is.
  345. ' ctrl_name     - The name of the picture box around which the frame is to be drawn.
  346. ' dn            - Indicates the style of the frame:
  347. '                   INSET   - The frame is drawn sunken.
  348. '                   RAISED  - The frame is drawn raised.
  349. '                   REMOVE  - The frame is removed (drawn in light gray).
  350.     
  351.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  352.     Dim x2 As Integer, y2 As Integer, x As Integer, y As Integer, i As Integer
  353.     Dim fleft As Integer, fright As Integer, ftop As Integer, fbottom As Integer ' coords
  354.     
  355.     Select Case dn ' assign colors depending on frame style
  356.         Case True ' Inset
  357.             col1 = DARKGRAY
  358.             col2 = WHITE
  359.             'col1 = RGB(128, 128, 128) ' Dark gray
  360.             'col2 = RGB(255, 255, 255) ' Bright white
  361.         Case False ' Raised
  362.             col1 = WHITE
  363.             col2 = DARKGRAY
  364.             'col1 = RGB(255, 255, 255) ' Bright white
  365.             'col2 = RGB(128, 128, 128) ' Dark gray
  366.         Case 2 ' Remove
  367.             col1 = LIGHTGRAY
  368.             col2 = LIGHTGRAY
  369.             'col1 = RGB(192, 192, 192) ' Light gray
  370.             'col2 = RGB(192, 192, 192) ' Light gray
  371.         Case Else ' Otherwise, it's an error
  372.             Exit Sub ' Exit subroutine
  373.     End Select
  374.     
  375.     x = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  376.     y = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  377.     
  378.     x2 = x * 2 ' Distance from edge
  379.     y2 = y * 2 ' Distance from edge
  380.         
  381.     ' First box
  382.     ctop = ctrl_name.Top - Screen.TwipsPerPixelY
  383.     cleft = ctrl_name.Left - Screen.TwipsPerPixelX
  384.     cright = ctrl_name.Left + ctrl_name.Width
  385.     cbottom = ctrl_name.Top + ctrl_name.Height
  386.     
  387.     form_name.Line (cleft - x, cbottom + y2)-(cright + x2 + x, cbottom + y2), col1 ' Draw individual lines
  388.     form_name.Line (cright + x2, ctop - y)-(cright + x2, cbottom + y2), col1
  389.     form_name.Line (cleft - x, ctop - y)-(cright + x2, ctop - y), col1
  390.     form_name.Line (cleft - x, ctop - y)-(cleft - x, cbottom + y2), col1
  391.         
  392.     'Second box
  393.     ctop = ctrl_name.Top - Screen.TwipsPerPixelY
  394.     cleft = ctrl_name.Left - Screen.TwipsPerPixelX
  395.     cright = ctrl_name.Left + ctrl_name.Width
  396.     cbottom = ctrl_name.Top + ctrl_name.Height
  397.     
  398.     form_name.Line (cleft - x2, cbottom + y)-(cright + x2, cbottom + y), col2 ' Draw individual lines
  399.     form_name.Line (cright + x, ctop - y2)-(cright + x, cbottom + y), col2
  400.     form_name.Line (cleft - x2, ctop - y2)-(cright + x, ctop - y2), col2
  401.     form_name.Line (cleft - x2, ctop - y2)-(cleft - x2, cbottom + y), col2
  402.  
  403. End Sub
  404.  
  405. Sub OutlinePicOnPic (pic_name As Control, ctrl_name As Control, dn As Integer)
  406.     
  407. ' This subroutine paints a 3D rectangle, with a 1 pixel bevel, around a picture box inside
  408. ' a container. Although it is meant to drawn around a container, it can be used with any
  409. ' control.
  410. '
  411. ' Parameters:
  412. ' pic_name      - The name of the container on which the picture box is.
  413. ' ctrl_name     - The name of the picture box around which the frame is to be drawn.
  414. ' dn            - Indicates the style of the frame:
  415. '                   INSET   - The frame is drawn sunken.
  416. '                   RAISED  - The frame is drawn raised.
  417. '                   REMOVE  - The frame is removed (drawn in light gray).
  418.     
  419.     Dim col1 As Long, col2 As Long ' variables for highlight and shadow colors
  420.     Dim x2 As Integer, y2 As Integer, x As Integer, y As Integer, i As Integer
  421.     Dim fleft As Integer, fright As Integer, ftop As Integer, fbottom As Integer ' coords
  422.     
  423.     Select Case dn ' assign colors depending on frame style
  424.         Case True ' Inset
  425.             col1 = DARKGRAY
  426.             col2 = WHITE
  427.             'col1 = RGB(128, 128, 128) ' Dark gray
  428.             'col2 = RGB(255, 255, 255) ' Bright white
  429.         Case False ' Raised
  430.             col1 = WHITE
  431.             col2 = DARKGRAY
  432.             'col1 = RGB(255, 255, 255) ' Bright white
  433.             'col2 = RGB(128, 128, 128) ' Dark gray
  434.         Case 2 ' Remove
  435.             col1 = LIGHTGRAY
  436.             col2 = LIGHTGRAY
  437.             'col1 = RGB(192, 192, 192) ' Light gray
  438.             'col2 = RGB(192, 192, 192) ' Light gray
  439.         Case Else ' Otherwise, it's an error
  440.             Exit Sub ' Exit subroutine
  441.     End Select
  442.     
  443.     x = Screen.TwipsPerPixelX ' Number of twips per pixel horizontally
  444.     y = Screen.TwipsPerPixelY ' Number of twips per pixel vertically
  445.     
  446.     x2 = x * 2 ' Distance from edge
  447.     y2 = y * 2 ' Distance from edge
  448.         
  449.     ' First box
  450.     ctop = ctrl_name.Top - Screen.TwipsPerPixelY
  451.     cleft = ctrl_name.Left - Screen.TwipsPerPixelX
  452.     cright = ctrl_name.Left + ctrl_name.Width
  453.     cbottom = ctrl_name.Top + ctrl_name.Height
  454.     
  455.     pic_name.Line (cleft - x, cbottom + y2)-(cright + x2 + x, cbottom + y2), col1 ' Draw individual lines
  456.     pic_name.Line (cright + x2, ctop - y)-(cright + x2, cbottom + y2), col1
  457.     pic_name.Line (cleft - x, ctop - y)-(cright + x2, ctop - y), col1
  458.     pic_name.Line (cleft - x, ctop - y)-(cleft - x, cbottom + y2), col1
  459.         
  460.     'Second box
  461.     ctop = ctrl_name.Top - Screen.TwipsPerPixelY
  462.     cleft = ctrl_name.Left - Screen.TwipsPerPixelX
  463.     cright = ctrl_name.Left + ctrl_name.Width
  464.     cbottom = ctrl_name.Top + ctrl_name.Height
  465.     
  466.     pic_name.Line (cleft - x2, cbottom + y)-(cright + x2, cbottom + y), col2 ' Draw individual lines
  467.     pic_name.Line (cright + x, ctop - y2)-(cright + x, cbottom + y), col2
  468.     pic_name.Line (cleft - x2, ctop - y2)-(cright + x, ctop - y2), col2
  469.     pic_name.Line (cleft - x2, ctop - y2)-(cleft - x2, cbottom + y), col2
  470.  
  471. End Sub
  472.  
  473.